#include<iostream>
#include<vector>
using namespace std;
const int N = 2e5 + 10;
int w[N];
int f1[N], f2[N];
int n, m;
vector<int>e[N];
struct node
{
	int u, v, k;
}q[N];

void dfs(int u, int fa, int ma, int mi)
{
	ma = max(ma + w[u], w[u]);
	mi = min(mi + w[u], w[u]);
	f1[u] = ma;
	f2[u] = mi;
	f1[u] = max(f1[u], f1[fa]);
	f2[u] = min(f2[u], f2[fa]);
	for (int v : e[u]) {
		dfs(v, u, ma, mi);
	}
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> m;
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			e[i].clear();
			q[i] = { 0,0,0 };
			f1[i] = f2[i] = 0;
			w[i] = 0;
		}
		n = 1;
		w[1] = 1;
		while (m--) {
			char op[2];
			cin >> op;
			if (op[0] == '+') {
				int v, w1;
				cin >> v >> w1;
				n++;
				e[v].push_back(n);
				w[n] = w1;
			}
			else {
				int u, v, k;
				cin >> u >> v >> k;
				q[++cnt] = { u,v,k };
			}
		}
		dfs(1, 0, 0, 0);
		for (int i = 1; i <= cnt; i++) {
			if (!q[i].k || f2[q[i].v] <= q[i].k && f1[q[i].v] >= q[i].k) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
	return 0;
}